var path = require('path');
var webpack = require('webpack');

var phaserModule = path.join(__dirname, '/node_modules/phaser/');
var phaser = path.join(phaserModule, 'build/custom/phaser-split.js');
var pixi = path.join(phaserModule, 'build/custom/pixi.js');
var p2 = path.join(phaserModule, 'build/custom/p2.js');

module.exports = {
  devtool: 'cheap-source-map',
  entry: {
    app: [
      'babel-polyfill',
      __dirname + '/app/index.js',
    ],
  },

  output: {
    path: __dirname + '/public/',
    filename: 'bundle.js',
  },

  module: {
    loaders: [
      {
        test: /\.js$/,
        include: path.join(__dirname, 'app'),
        loader: 'babel',
      },
      {
        test: /pixi\.js/,
        loader: 'expose?PIXI',
      },
      {
        test: /phaser-split\.js$/,
        loader: 'expose?Phaser',
      },
      {
        test: /p2\.js/,
        loader: 'expose?p2',
      },

    ],
  },
  resolve: {
    alias: {
      'phaser': phaser,
      'pixi': pixi,
      'p2': p2,
    },
  },
  devServer: {
    contentBase: './public',
    colors: true,
    historyApiFallback: true,
    inline: true,
    port: 5050,
  },
};
